//预览图片
function preview(src) {
    if (src == "") {
        return;
    }
    var image = new Image();
    image.src = src;
    var viewer = new Viewer(image, {
        hidden: function() {
            viewer.destroy();
        },
        navbar: false
    });
    viewer.show();
}
$().ready(function() {
	//预览
	$("#contentDiv").on("click",".preview",function(){
		preview($(this).attr("src"));
	});
	//图片删除
	$("#contentDiv").on("click",".picbox dd",function(){
		$(this).parent().remove();
	});
	//向左
   $("#contentDiv").on("click", ".toPicBefore",function() {
	   var chunkDiv = $(this).parent().parent();
	   var preChunkDiv = chunkDiv.prev();
	   if(preChunkDiv.length<1){
		   alert("已经到最前了");
		   return;
	   }
	   //节点替换
	   $(chunkDiv.prop("outerHTML")).insertBefore(preChunkDiv);
	   //移除
	   chunkDiv.remove();
   });
   //向右
   $("#contentDiv").on("click", ".toPicAfter",function() {
	   var chunkDiv = $(this).parent().parent();
	   var nextChunkDiv = chunkDiv.next();
	   if(nextChunkDiv.length<1){
		   alert("已经到最后了");
		   return;
	   }
	   //节点替换
	   $(chunkDiv.prop("outerHTML")).insertAfter(nextChunkDiv);
	   //移除
	   chunkDiv.remove();
   });

});